<?php

//笑话
class Joke
{
    public static function getJoke()
    {
        $url = 'http://v.juhe.cn/joke/randJoke.php';
        $key = 'cd53700d0c03a5b2a1374be7a8e15340';
        $curl = new Curl\Curl();
        $getData = $curl->get($url, array(
            'key' => $key,
        ));
        $getData = json_decode($getData->response, true);
        if ($getData['reason'] == 'success' && !empty($datas = $getData['result'])) {
            $result = [];
            foreach ($datas as $key => $data) {
                if ($key > 4) {
                    break;
                }
                $result[] = ++$key . ':' . $data['content'];
            };
            $res = implode('

', $result);
        } else {
            $res = '没有了哦';
        }
        return $res;
    }
}
